home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-102.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  46.7 KB  |  1,358 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Tue, 02 Jun 92       Volume 1 : Issue 102
  2.  
  3. Today's Topics:
  4.  
  5.     OpenMenuArchitecture/Other Questions...
  6.     HELP:  memory handling problem
  7.     Type Casting PixMaps to BitMaps in PASCAL!
  8.     Program hangs randomly - weird behaviour
  9.     question:THINK C console
  10.     Need a good book to teach me Mac assembly language
  11.     List Manager Question
  12.     LaunchApplication..
  13.     WWDC Dinner News
  14.     Must pascal strings be even word aligned?
  15.     Think C buggy code
  16.  
  17.  
  18. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  19.  
  20. These digests are available (by using FTP, account anonymous, your email
  21. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  22. edu.  This is also the home of the comp.sys.mac.programmer Frequently Asked
  23. Questions list.  The last several issues of the digest are available from
  24. sumex-aim.stanford.edu as well.
  25.  
  26. These digests are also available via email.  Just send a note saying that you
  27. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  28. automatically receive each new digest as it is created.
  29.  
  30. The digest is a collection of articles from the internet newsgroup comp.sys.
  31. mac.programmer.  It is designed for people who read c.s.m.p. semi-regularly
  32. and want an archive of the discussions.  If you don't know what a newsgroup
  33. is, you probably don't have access to it.  Ask your systems administrator(s)
  34. for details.  (This means you can't post questions to the digest.)
  35.  
  36. The articles in these digests are taken directly from comp.sys.mac.programmer.
  37. They are not edited; all articles included in this digest are in their original
  38. posted form.  The only articles that are -not- included in these digests are
  39. those which didn't receive any replies (except those that give information
  40. rather than ask a question).  All replies to each article are concatenated
  41. onto the original article in the order in which they were received.  Article
  42. threads are not added to the digests until the last article added to the
  43. thread is at least one month old (this is to ensure that the thread is dead
  44. before adding it to the digests).
  45.  
  46. Send administrative mail to mkelly@cs.uoregon.edu.
  47.  
  48. -------------------------------------------------------
  49.  
  50. From: klingspo@netlab.cis.brown.edu (Steve Klingsporn)
  51. Subject: OpenMenuArchitecture/Other Questions...
  52. Date: 30 Apr 92 19:51:39 GMT
  53. Organization: Brown University
  54.  
  55.  
  56. Does anyone know if there is a tech note describing the "Open Scripting
  57. Architecture" (sorry, not menu architecture) so that one's interface
  58. code is separated from one's "engine" code?  I am trying to make
  59. my program (SplitHex) "AppleScript-ready," so when it's released,
  60. all will work right.  What I do now is basically check for menu
  61. events, and if a certain item is hit, I send an Apple event to
  62. myself (a chore), and then process the Apple event the next time
  63. through.
  64.  
  65. Another question:  You are supposed to be able to have color icons
  66. in a menu, right?  Like in Finder 7 with the "Labels" menu.  I have
  67. tried with a bunch of icons the size of those in Finder 7 to no
  68. avail -- How can I have my own Labels menu?
  69.  
  70.  
  71. Thanks.
  72.  
  73. +++++++++++++++++++++++++++
  74.  
  75. From: leonardr@ccs.itd.umich.edu
  76. Organization: Campus Computing Sites, University of Michigan-Ann Arbor
  77. Date: Fri, 1 May 92 18:04:35 GMT
  78.  
  79. In article <tpj4bINNn1u@stanley.cis.Brown.EDU> klingspo@netlab.cis.brown.edu (Steve Klingsporn) writes:
  80. >
  81. >Does anyone know if there is a tech note describing the "Open Scripting
  82. >Architecture" (sorry, not menu architecture) so that one's interface
  83. >code is separated from one's "engine" code?  I am trying to make
  84. >my program (SplitHex) "AppleScript-ready," so when it's released,
  85. >all will work right.  What I do now is basically check for menu
  86. >events, and if a certain item is hit, I send an Apple event to
  87. >myself (a chore), and then process the Apple event the next time
  88. >through.
  89. >
  90.     I don't believe there is a technotes, but these issues will be 
  91. covered in great detail at the WWDC.
  92.  
  93.     There are different levels of "OSA Compliance" (note these terms are
  94. not official, but they are currently being used) - scriptable, recordable,
  95. attachable and tinkerable.
  96.  
  97.     Scriptable implies that you support more than the required Apple
  98. events and that you include an 'aete' resource.  
  99.  
  100.     Recordable means that you send events to yourself (using the special 
  101. kCurrentProcess trick) that an EventRecorder can pick up.  You should be 
  102. sending to self ALL user actions that have Apple events.  
  103.     For example in StuffIt 3.0 I record everything
  104. from creating a new archive, to stuffing & unstuffing items to even a
  105. simple rename or delete or an item.  AEQuill (Apple's sample) even records
  106. window movement, since it has an event for that!
  107.  
  108.     Attachable means that you can execute OSAScripts (AppleScripts) from
  109. within your program directly (button, menu, etc.).  You may also want to
  110. allow users to integrate AScript into your own scripting language - ie. mix
  111. them!
  112.  
  113.     Tinkerable is still pretty undefined, but was originally proposed as
  114. a way to describe future application that would allow their built-in 
  115. functionality to be "overridden" by scripts.
  116.  
  117.  
  118. >Another question:  You are supposed to be able to have color icons
  119. >in a menu, right?  Like in Finder 7 with the "Labels" menu.  I have
  120. >tried with a bunch of icons the size of those in Finder 7 to no
  121. >avail -- How can I have my own Labels menu?
  122. >
  123.     Write your own MDEF.  That's what we do in StuffIt!
  124.  
  125.  
  126. - -- 
  127. - -----------------------------------------------------------------------
  128. Leonard Rosenthol          Internet: leonardr@ccs.itd.umich.edu
  129. Director of Advanced Technology   AppleLink: MACgician
  130. Aladdin Systems, inc.          GEnie:     MACgician
  131.  
  132. +++++++++++++++++++++++++++
  133.  
  134. From: mlanett@void.ncsa.uiuc.edu (Mark Lanett)
  135. Date: 1 May 92 19:21:49 GMT
  136. Organization: University of Illinois at Urbana
  137.  
  138. leonardr@ccs.itd.umich.edu writes:
  139.  
  140. >In article <tpj4bINNn1u@stanley.cis.Brown.EDU> klingspo@netlab.cis.brown.edu (Steve Klingsporn) writes:
  141.  
  142. >>Another question:  You are supposed to be able to have color icons
  143. >>in a menu, right?  Like in Finder 7 with the "Labels" menu.  I have
  144. >>tried with a bunch of icons the size of those in Finder 7 to no
  145. >>avail -- How can I have my own Labels menu?
  146. >>
  147. >    Write your own MDEF.  That's what we do in StuffIt!
  148.  
  149. Ack! The standard MDEF handles color icons just fine. Just create a cicn
  150. with 256 < resource id < 511 and set the icon number in the menu item to
  151. resource id - 256, and you're set. Works exactly the same as normal ICN# and
  152. sicns always did. I haven't tried sizes other than 16x16, though.
  153.  
  154. Wierd hack: create a 64x64 cicn of id=256 and put it in the system. It doesn't
  155. matter what it looks like, it'll just have a certain effect on other cicns...
  156.  
  157. Mark L
  158. - -- 
  159. Mark Lanett, NCSA Software Development                         mlanett@uiuc.edu
  160.  
  161. ---------------------------
  162.  
  163. From: peterc@moebius.cubetech.com (Peter Creath)
  164. Subject: HELP:  memory handling problem
  165. Date: 29 Apr 92 12:38:57 GMT
  166. Organization: Cube Technologies
  167.  
  168. This seems to be giving me random crashes.  What am I doing wrong?
  169. (A Hermes sysop external gets message similar to those from the Control
  170. Panel):
  171.  
  172.  
  173. typedef struct {
  174.     DialogPtr    BigDialog;
  175.     short        currentWindow;
  176.     } myStruct;
  177.  
  178. myStruct        *myVars;
  179.  
  180. pascal void main(short message, short item, EventRecord *theEvent,
  181.     HermDataPtr myHerm, long *XHRMrefcon, DialogPtr ConfigDialog)
  182. {
  183. if (message == initDev) {
  184.     *XHRMrefcon = (long)NewHandle(sizeof(myStruct));
  185.     if (*XHRMrefcon) {
  186.         MoveHHi((Handle)*XHRMrefcon);
  187.         HNoPurge((Handle)*XHRMrefcon);
  188.         }
  189.     else SysBeep(1);
  190.     }
  191.  
  192. if (!*XHRMrefcon) return;
  193.  
  194. HLock((Handle)*XHRMrefcon);
  195. myVars = (myStruct *)(*((Handle)*XHRMrefcon));
  196.  
  197. switch (message) {
  198.     case initDev:
  199.         myVars->currentWindow = 0;
  200.         myVars->BigDialog = 0L;
  201.         break;
  202.     case closeDev:
  203.         HUnlock((Handle)*XHRMrefcon);
  204.         HPurge((Handle)*XHRMrefcon);
  205.         DisposHandle((Handle)*XHRMrefcon);
  206.         *XHRMrefcon = 0L;
  207.         return;
  208.         break;
  209.     }
  210. HUnlock((Handle)*XHRMrefcon);
  211. }
  212.  
  213. - ----------------------------------------------------------------------------
  214. Peter Creath                 "When I was a boy I was told that anybody could
  215. peterc@moebius.cubetech.com   become president; I'm beginning to believe it."
  216.                                                            -- Clarence Darrow
  217.  
  218. +++++++++++++++++++++++++++
  219.  
  220. From: keith@taligent.com (Keith Rollin)
  221. Date: 1 May 92 19:45:27 GMT
  222. Organization: Taligent
  223.  
  224. In article <dx3uv972.27t809@moebius.cubetech.com>, peterc@moebius.cubetech.com
  225. (Peter Creath) writes:
  226. > This seems to be giving me random crashes.  What am I doing wrong?
  227. > (A Hermes sysop external gets message similar to those from the Control
  228. > Panel):
  229. >
  230.  
  231. I don't know what's causing you to crash. If you could tell us which line is
  232. causing the crash and why (like "register A0 is bogus"), that would help. In the
  233. meantime, I like to point out a couple of other things (none of which would
  234. cause the crash).
  235.  
  236. > typedef struct {
  237. >     DialogPtr    BigDialog;
  238. >     short        currentWindow;
  239. >     } myStruct;
  240. > myStruct        *myVars;
  241. > pascal void main(short message, short item, EventRecord *theEvent,
  242. >     HermDataPtr myHerm, long *XHRMrefcon, DialogPtr ConfigDialog)
  243. > {
  244. > if (message == initDev) {
  245. >     *XHRMrefcon = (long)NewHandle(sizeof(myStruct));
  246. >     if (*XHRMrefcon) {
  247. >         MoveHHi((Handle)*XHRMrefcon);
  248. >         HNoPurge((Handle)*XHRMrefcon);
  249.  
  250. You do not need either of these commands. All MoveHHi will do is waste time. If
  251. you don't lock down the handle after you've moved it high, it will just get
  252. moved around again. Since you don't want to lock the handle at this time, you
  253. don't want the call to MoveHHi, either.
  254.  
  255. Neither do you need the call to HNoPurge. Handles are unpurgeable by default.
  256.  
  257. >         }
  258. >     else SysBeep(1);
  259. >     }
  260. > if (!*XHRMrefcon) return;
  261. > HLock((Handle)*XHRMrefcon);
  262. > myVars = (myStruct *)(*((Handle)*XHRMrefcon));
  263.  
  264. You do not need to lock the handle here, since you aren't doing anything to move
  265. memory. In the likely case that your REAL external is more complicated and does
  266. move memory around, then you may simply want to lock the handle around the
  267. critical sections of your code.
  268.  
  269. If you _DO_ lock the handle because you are allocating memory, then you may want
  270. to call MoveHHi just before locking it. For instance, if myVars->BigDialog is
  271. used to point to a dialog that you have created, then you might want to move
  272. your locked handle out of the way before it is created.
  273.  
  274. > switch (message) {
  275. >     case initDev:
  276. >         myVars->currentWindow = 0;
  277. >         myVars->BigDialog = 0L;
  278. >         break;
  279. >     case closeDev:
  280. >         HUnlock((Handle)*XHRMrefcon);
  281. >         HPurge((Handle)*XHRMrefcon);
  282. >         DisposHandle((Handle)*XHRMrefcon);
  283.  
  284. You do not need to unlock and mark purgeable a handle that you are nuking. Just
  285. call DisposeHandle(). It will work on locked, unpurgeable handles.
  286.  
  287. >         *XHRMrefcon = 0L;
  288. >         return;
  289. >         break;
  290. >     }
  291. > HUnlock((Handle)*XHRMrefcon);
  292. > }
  293.  
  294. - --
  295. Keith Rollin
  296. Phantom Programmer
  297. Taligent, Inc.
  298.  
  299.  
  300. ---------------------------
  301.  
  302. From: Josh.Adams@bbs.oit.unc.edu (Josh Adams)
  303. Subject: Type Casting PixMaps to BitMaps in PASCAL!
  304. Date: 27 Apr 92 18:47:28 GMT
  305. Organization: Extended Bulletin Board Service
  306.  
  307. Please xcuse that lst message, I didn't know my first one had gotten posted
  308. until after I posted the second one which said the same thing, and when I 
  309. tried to cancel it , the comp said it wasn't my message. Anyway...
  310.  
  311. I got some reaction to the last one, but I need to know (I think I need to know
  312. how to type cast a PixMap to a BitMap in PASCAL, so I can use it with 
  313. CopyBits. I think that is how I should do it, since they never made a damn
  314. CopyPix which does the same thing as CopyBits. THe one they wrote doesn't
  315. help me at all...
  316.  
  317. Anyway, any help about the type-casting thing would help,thanks...
  318. Josh
  319.  
  320. - --
  321.    The opinions expressed are not necessarily those of the University of
  322.      North Carolina at Chapel Hill, the Campus Office for Information
  323.         Technology, or the Experimental Bulletin Board Service.
  324.            internet:  bbs.oit.unc.edu or 152.2.22.80
  325.  
  326. +++++++++++++++++++++++++++
  327.  
  328. From: mhall@occs.cs.oberlin.edu (Matthew Hall)
  329. Date: 28 Apr 92 04:05:19 GMT
  330. Organization: Oberlin College Computer Science
  331.  
  332. In article <1992Apr27.184728.1224@samba.oit.unc.edu> Josh.Adams@bbs.oit.unc.edu (Josh Adams) writes:
  333.  
  334.  
  335. >   I got some reaction to the last one, but I need to know (I think I need to know
  336. >   how to type cast a PixMap to a BitMap in PASCAL, so I can use it with 
  337. >   CopyBits. I think that is how I should do it, since they never made a damn
  338. >   CopyPix which does the same thing as CopyBits. THe one they wrote doesn't
  339. >   help me at all...
  340. >
  341.  
  342. All right - One way to do this with 32 bit QD is to use the
  343. QDOffScreen library and use GWorlds.  However, I don't know how to do
  344. this so heres the hard way.
  345.  
  346. var MyColorPort : GrafPtr;  {Yes, not a CGrafPtr}
  347.  
  348. ...
  349. new(MyColorPort);
  350. OpenCPort(MyColorPort); {Will return a color port}
  351.  
  352. HLock(Handle(MyColorPort^.PortPixMap));   {Lock the ports pixmap}
  353. With MyColorPort^.PortPixMap^^ do     
  354.   begin
  355.     rowbytes:=(width*depth)/8 +extra {must be even, better if multiple of 4}
  356.     setrect(bounds,top,left,bottom,right);
  357.     baseaddr:=newptr(rowbytes*(bottom-top));
  358.  
  359.     rowbytes:= BOR(Rowbytes,$8000);  {The high bit of rowbytes must be
  360. set for QuickDraw to realize that it's a pixmap}
  361.   end;
  362.  
  363. {A good thing to do is to set the cliprgn of MyColorPort to the
  364. boundsrect, otherwise you might overwrite memory if you draw outside a
  365. box.  Hence Application Zone Damaged}
  366. RectRgn(MyColorPort^.cliprgn,MyColorPort^.portpixmap^^.bounds);
  367. HUnlock(MyColorPort^.portpixmap);
  368.  
  369.  
  370. Now, when you want to draw in it, just setport(MyColorPort).  If you
  371. want to copy from it, use
  372.  
  373. SetPort(MyWindow);
  374. Copybits(MyColorPort^.portbits,MyWindow^.portbits, srcrect, dstrect,
  375. copymode, copyrgn);
  376.  
  377. ColorQuickdraw senses that it's a pixmap (remember setting the high
  378. bit of rowbytes?) and copies accordingly.
  379.  
  380. hope this helps
  381. - -matt hall
  382.  
  383. - --
  384.  
  385.  
  386. - -------------------------------------------------------------------------------
  387. Matt Hall.    mhall@occs.cs.edu  OR  SMH9666@OBERLIN.BITNET
  388.               (216)-775-5805 (That's a Cleveland Area code. Lucky Me)
  389.  
  390. "If a man comes up to you and says:
  391.     'A dog just carried away your ear.'
  392. Do you run after the dog, or search first for your ear?" - Moon over Morocco
  393.   
  394.  
  395. +++++++++++++++++++++++++++
  396.  
  397. From: torello@alessia.dei.unipd.it (Tommaso Centro 310125/IF {*})
  398. Date: 29 Apr 92 03:38:14 GMT
  399. Organization: D.E.I. Universita' di Padova (Italy)
  400.  
  401.  
  402. To copy a pixel map from an off screen color port to a color window for
  403. example i would do like this:
  404. ( VAR offPort : CGrafPtr;
  405.       myWindowBw : WindowPtr
  406.       myWindowCol : CWindowPtr )
  407.  
  408.  CopyBits(GrafPtr(offPort)^.portBits,GrafPtr(myWindowCol)^.portBits,...);
  409.  or (it's the same): CopyBits(...,GrafPtr(myWindowBw)^.portBits,...);
  410.  
  411. but if you want to use directly pixel maps you can put in your program:
  412.  
  413.  procedure CopyBits(srcBits:PixMap;dstBits:PixMap;srcRect:Rect;...etc);
  414.  inline
  415.  $A8EC;
  416.  
  417. and the previous statement becomes:
  418.  
  419.  CopyBits(offPort^.portPixMap^^,myWindowCol^.portPixMap^^,...);
  420.  
  421. to have a CWindowPtr you can do like this:
  422.  myWindowBw:=NewCWindow(..);
  423.  myWindowCol:=CWindowPtr(myWindowBw);
  424. or:
  425.  myWindowCol:=CWindowPtr(NewCWindow(...));
  426.  
  427. I hope this helps.
  428.  
  429. Ciao
  430. Tommaso
  431.  
  432. +++++++++++++++++++++++++++
  433.  
  434. From: torello@alessia.dei.unipd.it (Tommaso Centro 310125/IF {*})
  435. Date: 29 Apr 92 03:29:01 GMT
  436. Organization: D.E.I. Universita' di Padova (Italy)
  437.  
  438. To copy a pixel map from an off screen color port to a color window for
  439. example i would do like this:
  440. ( VAR offPort : CGrafPtr;
  441.       myWindowBw : WindowPtr
  442.       myWindowCol : CWindowPtr )
  443.  
  444.  CopyBits(GrafPtr(offPort)^.portBits,GrafPtr(myWindowCol)^.portBits,...);
  445.  or (it's the same): CopyBits(...,GrafPtr(myWindowBw)^.portBits,...);
  446.  
  447. but if you want to use directly pixel maps you can put in your program:
  448.  
  449.  procedure CopyBits(srcBits:PixMap;dstBits:PixMap;srcRect:Rect;...etc);
  450.  inline
  451.  $A8EC;
  452.  
  453. and the previous statement becomes:
  454.  
  455.  CopyBits(offPort^.portPixMap^^,myWindowCol^.portPixMap^^,...);
  456.  
  457. to have a CWindowPtr you can do like this:
  458.  myWindowBw:=NewCWindow(..);
  459.  myWindowCol:=CWindowPtr(myWindowBw);
  460. or:
  461.  myWindowCol:=CWindowPtr(NewCWindow(...));
  462.  
  463. I hope this helps.
  464.  
  465. Ciao
  466. Tommaso
  467.  
  468. +++++++++++++++++++++++++++
  469.  
  470. From: jcav@quads.uchicago.edu (JohnC)
  471. Date: 29 Apr 92 18:45:13 GMT
  472. Organization: The Royal Society for Putting Things on Top of Other Things
  473.  
  474. In article <1992Apr29.033814.10931@sabrina.dei.unipd.it> torello@alessia.dei.unipd.it (Tommaso Centro 310125/IF {*}) writes:
  475. >but if you want to use directly pixel maps you can put in your program:
  476. > procedure CopyBits(srcBits:PixMap;dstBits:PixMap;srcRect:Rect;...etc);
  477. > inline
  478. > $A8EC;
  479. >and the previous statement becomes:
  480. > CopyBits(offPort^.portPixMap^^,myWindowCol^.portPixMap^^,...);
  481.  
  482. Excellent idea, except _please_ don't re-define the existing name.  Instead,
  483. you should add something like the following:
  484.  
  485.   procedure CopyPix(srcPix:PixMap;dstPix:PixMap;srcRect:Rect;...etc);
  486.   inline
  487.   $A8EC;
  488.  
  489.   procedure CopyBitsToPix(srcBits:BitMap;dstPix:PixMap;srcRect:Rect;...etc);
  490.   inline
  491.   $A8EC;
  492.  
  493.   procedure CopyPixToBits(srcPix:PixMap;dstBits:BitMap;srcRect:Rect;...etc);
  494.   inline
  495.   $A8EC;
  496.  
  497.  
  498. There, that covers all the possibilities. :-)
  499.  
  500. - -- 
  501. John Cavallino                  |  EMail: jcav@midway.uchicago.edu
  502. University of Chicago Hospitals |         John_Cavallino@uchfm.bsd.uchicago.edu
  503. Office of Facilities Management | USMail: 5841 S. Maryland Ave, MC 0953
  504. B0 f++ c+ g+ k s++ e+ h- pv     |         Chicago, IL  60637
  505.  
  506. +++++++++++++++++++++++++++
  507.  
  508. From: jmatthews@desire.wright.edu
  509. Date: 30 Apr 92 18:21:14 EST
  510. Organization: Wright State University 
  511.  
  512. In article <1992Apr29.184513.18791@midway.uchicago.edu>, jcav@quads.uchicago.edu (JohnC) writes:
  513. > In article <1992Apr29.033814.10931@sabrina.dei.unipd.it> torello@alessia.dei.unipd.it (Tommaso Centro 310125/IF {*}) writes:
  514. > Excellent idea, except _please_ don't re-define the existing name.  Instead,
  515. > you should add something like the following:
  516. >   procedure CopyPix(srcPix:PixMap;dstPix:PixMap;srcRect:Rect;...etc);
  517. >   inline
  518. >   $A8EC;
  519. [ variations omitted ]
  520.  
  521. IM V tells us that CopyBits uses the portVersifield of a CGrafPort
  522. to decide if it's been handed a BitMap or a PixMapHandle. At the
  523. same time, CopyBits appears to be happy with a PixMap (passed by
  524. address). Is this CopyBits magic or am I overlooking something
  525. obvious.
  526.  
  527. o----------------------------------------------------------------------------o
  528. | John B. Matthews, jmatthews@desire.wright.edu, disclaimer:= myViews <> WSU |
  529. | "I'm a commensal .sig virus, indistinguishable from an ordinary organelle."|
  530. o----------------------------------------------------------------------------o
  531.  
  532. ---------------------------
  533.  
  534. From: jerry@uni-paderborn.de (Gerald Siek)
  535. Subject: Program hangs randomly - weird behaviour
  536. Date: 29 Apr 92 14:03:47 GMT
  537. Organization: Uni-GH Paderborn
  538.  
  539. Hello experts!
  540.  
  541. I have a *very* weird problem:
  542. I'm porting a huge UNIX programm (a computer algebra system) to the 
  543. Macintosh.   The port was not too difficult but after a few weeks
  544. the program began to behave very strange.
  545.  
  546. The program does not always start up correctly, sometime it simply
  547. seems to hang in a loop.  The Mac does not crash, I can still move
  548. the mouse but the program does not finish it's initialization.
  549. When I trace the program with the debugger it always runs fine so
  550. I have no possibility to see where it hangs.
  551.  
  552. So I put output commands (commands that write "Now executing xyz" in
  553. a window) at several places in the initialization part to see which 
  554. routines are executed correctly.  And now the program works *fine*.  
  555. When I remove the output commands the program becomes unstable again.
  556.  
  557. I have no real idea what could be the reason for this.  The programm simply
  558. behaves different when I add the output commands.  The program makes
  559. heavy use of malloc and free calls and shuffels LARGE amounts of memory.
  560. Has anyone encountered a similar problem?  Perhaps a memory management
  561. problem? (I use THINK C 5.0.2)
  562.  
  563. ANY help, ANY clue is greatly appreciated
  564.  
  565. Thanks
  566.     Jerry
  567. - -- 
  568.   Gerald Siek  -  jerry@uni-paderborn.de  -  University of Paderborn, Germany
  569.  
  570. +++++++++++++++++++++++++++
  571.  
  572. From: sasdtm@stthomas.unx.sas.com (Donald T. Major)
  573. Organization: SAS Institute Inc.
  574. Date: Wed, 29 Apr 1992 18:02:18 GMT
  575.  
  576. In article <1992Apr29.140347.22788@uni-paderborn.de>, jerry@uni-paderborn.de (Gerald Siek) writes:
  577.  [stuff deleted]
  578. |> When I trace the program with the debugger it always runs fine so
  579. |> I have no possibility to see where it hangs.
  580.  [stuff deleted]
  581. |> So I put output commands (commands that write "Now executing xyz" in
  582. |> a window) at several places in the initialization part to see which
  583. |> routines are executed correctly.  And now the program works *fine*.
  584. |> When I remove the output commands the program becomes unstable again.
  585.  [stuff deleted]
  586.  
  587. Any time I see something like this in my mac code, it has always been a
  588. sign of either uninitialized variables or insufficiently allocated
  589. variables (static, automatic, or dynamic).
  590.  
  591.                                                      ..
  592.                                                     dtm
  593.  
  594. - -- 
  595. Donald Major       SAS Institute Inc.  "Cicely, let's fling something!"
  596. sasdtm@unx.sas.com SAS Campus Drive                 - Northern Exposure
  597. (919) 677-8000     Cary, NC 27513-2414
  598.  
  599. +++++++++++++++++++++++++++
  600.  
  601. From: jack@umbio.med.miami.edu (Jack Herrington)
  602. Date: 1 May 92 19:50:08 GMT
  603. Organization: University of Miami Medical School
  604.  
  605. jerry@uni-paderborn.de (Gerald Siek) writes:
  606. : The program does not always start up correctly, sometime it simply
  607. : seems to hang in a loop.  The Mac does not crash, I can still move
  608. : the mouse but the program does not finish it's initialization.
  609. : When I trace the program with the debugger it always runs fine so
  610. : I have no possibility to see where it hangs.
  611.  
  612. Look for large external or internal (inside procedures) initization's of
  613. variables.  If you find them, replace them with a NewPtr or NewHandle (but
  614. if you use handles, start reading the memory manager sections on HLock
  615. HUnlock, HGetState, and HSetState).  These types of problems will be
  616. especially evident when you move between different types of Macs, Mac
  617. Pluses do not allow a great amount of external space, while a Mac II CX is
  618. more forgiving.
  619.  
  620. - -Jack
  621. - -- 
  622. "Electric word 'life', it means forever and that's a might long time.  But I'm
  623.  here to tell yah, there's something else... The after-life, a word of
  624.  never-ending happiness, you can always see the sun, day or night.  So when you
  625.  call up that shrink in Beverly hills, you know the one, Dr. everything-we-all-
  626.  
  627. ---------------------------
  628.  
  629. Subject: question:THINK C console
  630. From: eburk@russian.sfsu.edu (Eli K. Burk)
  631. Date: 30 Apr 92 19:47:06 PDT
  632.  
  633. I posted to this group a few weeks ago about using THINK C while
  634. learning C and the mac environment.
  635.  
  636. I have learned that I am best served just learning C. It keeps
  637. me plenty busy. So now my question becomes - how can I modify
  638. the console package to: 
  639.     1) support a scroll bar
  640.     2) exit like a "regular mac app" by command-q ONLY
  641.     3) have the name of my "simple console app" appear
  642.            on the title bar of the window (it may aready do
  643.        this - I haven't used THINK C in weeks)
  644.     4) cut and paste ability (if this is complex - I'll skip it...)
  645. Also I want to learn just enough about resources to be able to:
  646.     1) use the info menu
  647.     2) set an icon to "simple console app"
  648. Has anyone tired to use the curses package in THINK C - I know
  649. this is a waste - but I just don't have the time now to learn
  650. *real* mac programming. - Also I don't even own a mac... 
  651.  
  652. If my questions include errors or misstatements just correct me.
  653.  
  654. email please.
  655.  
  656. - --
  657. Eli Burk                   eburk@sutro.sfsu.edu  <---NeXT mail ok
  658. P.O. Box 22135             "de do do do de da da da" sting at his best
  659. San Francisco, CA 94122    "me me me me me me me me" sting at his worst
  660.  
  661.  
  662. ---------------------------
  663.  
  664. From: westphal@css.itd.umich.edu (Brian Westphal)
  665. Subject: Need a good book to teach me Mac assembly language
  666. Date: 1 May 92 05:58:19 GMT
  667. Organization: University of Michigan, ITD Consulting and Support Services
  668.  
  669. I am interested in learning the ins and outs of assembly language programming
  670. for the Mac, and am wondering which book could best help me to do this.  I
  671. already know and use assembly on other machines so it isn't new to me, but I
  672. don't know the instruction set for the 60xxx series, and all the fine points
  673. that are Mac specific.  If you know of a great book that can help me do this
  674. please e-mail me.  Also, what's the best Mac assembler?  Do I have to invest
  675. in MPW?  I would rather not.  Thanks to all.
  676. - --
  677. _______________________________________________________________________________
  678. MMMMMMMMM        MMMMMMMMM |                   Brian Westphal
  679. MMMMMMMMMM      MMMMMMMMMM |               College of Engineering
  680. MMMMMMMMMMM    MMMMMMMMMMM |---------------------------------------------------
  681.  
  682. +++++++++++++++++++++++++++
  683.  
  684. From: zben@ni.umd.edu (Charles B. Cranston)
  685. Organization: UM Home for the Terminally Analytical
  686. Date: Fri, 1 May 1992 22:01:06 GMT
  687.  
  688. In article <1992May1.055819.1605@terminator.cc.umich.edu>, westphal@css.itd.umich.edu (Brian Westphal) writes:
  689.  
  690. > I am interested in learning the ins and outs of assembly language programming
  691. > for the Mac, and am wondering which book could best help me to do this.  I
  692.  
  693. You need the Motorola book(s) on the 680x0 processor itself
  694.  
  695. Then maybe one of these:
  696.  
  697. "The Complete Book Of Macintosh Assembly Language Programming"
  698. (Dan Weston, two volume set)
  699. Scott Foresman & Co ISBN #s 0-673-18379-3 & 0-673-18583-4 
  700.  
  701. "Programming the Macintosh in Assembly Language"
  702. (James W. Coffron and/or Steve Williams?)
  703. SYBEX ISBN 0-89588-263-9
  704.  
  705. "Programming the 68000: Macintosh Assembly Language"
  706. (Edwin Rosenzweig and Harland Harrison)
  707. Hayden ISBN 0-8104-6310-5
  708.  
  709. "MPW and Assembly Language Programming For The Macintosh"
  710. (Scott Kronick)
  711. Hayden ISBN 0-672-48409-9
  712.  
  713.  
  714. ---------------------------
  715.  
  716. From: steve.herman%express@freedom.msfc.nasa.gov (Steve Herman)
  717. Subject: List Manager Question
  718. Organization: Boeing Computer Support Services (BCSS)
  719. Date: Fri, 1 May 1992 20:08:33 GMT
  720.  
  721.      I'm attempting to use the List Manager to create a list box which 
  722. contains 2 columns of related strings.  I would like to be able to highlight 
  723. the entire row (ie both columns) whenever a cell is clicked.  This seems to 
  724. be relatively simple except while LClick() is tracking the mouse.  While 
  725. LClick() is handling the mouse tracking only the single cell under the mouse 
  726. is highlighted.  It would certainly look nicer if I could highlight the 
  727. entire row while the mouse was being tracked.
  728.  
  729.     Does anyone know if this can be done?  I'm working in THINK C 5.0.
  730.  
  731.  
  732. Thanks,
  733. Steve
  734.  
  735. - -------------------------------------
  736. Steve Herman
  737. "Happiness is just a 'Flaming Moe' away"
  738. - -------------------------------------
  739.  
  740. +++++++++++++++++++++++++++
  741.  
  742. From: dougm@cns.caltech.edu (Doug McNaught)
  743. Organization: California Institute of Technology
  744. Date: Sat, 2 May 1992 05:05:12 GMT
  745.  
  746. In article <1992May1.200833.14085@lambda.msfc.nasa.gov> steve.herman%express@freedom.msfc.nasa.gov (Steve Herman) writes:
  747.  
  748.  
  749. >   I'm attempting to use the List Manager to create a list box which
  750. >contains 2 columns of related strings.  I would like to be able to
  751. >highlight the entire row (ie both columns) whenever a cell is
  752. >clicked.  This seems to be relatively simple except while LClick() is
  753. >tracking the mouse.  While LClick() is handling the mouse tracking
  754. >only the single cell under the mouse is highlighted.  It would
  755. >certainly look nicer if I could highlight the entire row while the
  756. >mouse was being tracked.
  757.  
  758.  
  759. >   Does anyone know if this can be done?  I'm working in THINK C 5.0.
  760.  
  761.   If these two strings will never be selected separately, this should
  762. be fairly easy. Just store both strings in one cell (using whatever
  763. data structure you like) and write an LDEF that draws them both. If
  764. there is some case where one of the columns will be individually
  765. selected, you'd have to patch something out and be generally skanky.
  766. >From your text above it looks like the first solution will do fine for
  767. you. Don't be scared by LDEFs, they're really easy.
  768.  
  769. regards,
  770. doug
  771. - --
  772. Doug McNaught              |"Sadder still to watch it die/ Then never to have
  773. dougm@cns.caltech.edu      | known it/ For you, the blind who once could see/
  774. mcnaught@midget.towson.edu | The bell tolls for thee..." --Neil Peart
  775.   Nobody approves my opinions! Not even me, sometimes. Read at your own risk.
  776.  
  777. ---------------------------
  778.  
  779. From: shall@yoda.eecs.wsu.edu (Sean Hall - CS460)
  780. Subject: LaunchApplication..
  781. Organization: Washington State University
  782. Date: Fri, 1 May 92 20:49:35 GMT
  783.  
  784. I am trying to launch one app from another.  In experimenting with THINK C 5
  785. I find that launching another app causes the launching app to quit.  Also,
  786. if I try using the ansi library printf, it bombs or dont work at all.  This is
  787. a mystery to me.  I have multifinder aware, accept HLE marked in the project.
  788. Also, the receiving app accepts HLE and works fine if double clicked.
  789. Here is the code for the "sender"
  790.  
  791. #include <AppleEvents.h>
  792. #include <processes.h>
  793. #define NIL 0
  794. void mySend(void);
  795.  
  796. main()
  797. {
  798. OSErr myErr;
  799. DTPBRec DTpb;
  800. FSSpec myFSSpec;
  801. LaunchParamBlockRec    L;
  802. Str255 name;
  803. int x;
  804.  
  805.     DTpb.ioVRefNum = -1;
  806.     DTpb.ioNamePtr = name;
  807.     
  808.     myErr = PBDTGetPath(&DTpb);
  809.     DTpb.ioFileCreator = (long)'MyAp';
  810.     DTpb.ioIndex = 0;
  811.     myErr = PBDTGetAPPLSync(&DTpb);
  812.     myErr = FSMakeFSSpec(DTpb.ioVRefNum,DTpb.ioAPPLParID,
  813.                  DTpb.ioNamePtr, &myFSSpec);
  814.     L.launchBlockID = extendedBlock;
  815.     L.launchEPBLength = extendedBlockLen;
  816.     L.launchControlFlags = launchNoFileFlags;
  817.     L.launchAppParameters = 0;
  818.     L.launchAppSpec = &myFSSpec;
  819.     
  820.     LaunchApplication(&L);
  821. }
  822.  
  823. Comments welcome.
  824. - -Sean
  825.  
  826.  
  827. +++++++++++++++++++++++++++
  828.  
  829. From: haynes@mace.cc.purdue.edu (Carl W. Haynes III)
  830. Date: 2 May 92 00:33:01 GMT
  831. Organization: Purdue University Computing Center
  832.  
  833. In article <1992May1.204935.17061@serval.net.wsu.edu> shall@yoda.eecs.wsu.edu (Sean Hall - CS460) writes:
  834. >I am trying to launch one app from another.  In experimenting with THINK C 5
  835. >I find that launching another app causes the launching app to quit.  Also,
  836. >if I try using the ansi library printf, it bombs or dont work at all.  This is
  837. >a mystery to me.  I have multifinder aware, accept HLE marked in the project.
  838. >Also, the receiving app accepts HLE and works fine if double clicked.
  839. >Here is the code for the "sender"
  840. >
  841.  
  842.    [most of the code deleted]
  843.  
  844. >    L.launchBlockID = extendedBlock;
  845. >    L.launchEPBLength = extendedBlockLen;
  846. >    L.launchControlFlags = launchNoFileFlags;
  847.                            ^^^^^^^^^^^^^^^^^^
  848.  
  849. This is the problem, it should read:
  850.  
  851.     L.launchControlFlags = launchNoFileFlags + launchContinue;
  852.  
  853. IM VI 29-15 has a description of all the flags available
  854.  
  855. carl
  856. haynes@mace.cc.purdue.edu
  857. AOL: CWH3
  858.  
  859. ---------------------------
  860.  
  861. From: peirce@outpost.SF-Bay.org (Michael Peirce)
  862. Subject: WWDC Dinner News
  863. Date: 24 Apr 92 23:47:01 GMT
  864. Organization: Peirce Software
  865.  
  866. We're just shy of 50 people.  I'll be checking with Gorden Biersch
  867. about accomidating us.  I *think* they can handle it.
  868.  
  869. We'll be meeting at the main doors of the San Jose Convention Center
  870. (where the WWDC is held) at 7:45 and then head over there en masse.
  871.  
  872. (And I though all the Mac people had defected to Windows! :-)
  873.  
  874. Stephan Somogyi                    MacUserLabs@cup.portal.com
  875. Marshall Clow                    marshall@sdd.hp.com
  876. Rick Holzgraf                    Rick_Holzgrafe@taligent.com
  877. Larry Rosenstein                lsr@taligent.com
  878. Oliver Breidenbach                breidenb@informatik.tu-muenchen.de
  879. Michael Hecht                    Michael_Hecht@mac.sas.com
  880. Roland Mansson                    roland.mansson@ldc.lu.se
  881. Jon W{tte + 1                    h+@nada.kth.se
  882. Grobbins                        grobbins@apple.com
  883. Amanda Walker                    amanda@visix.com
  884. Owen M. Hartnett                omh@cs.brown.edu
  885. D. Jay Newman                    dn5@psuvm.psu.edu
  886. Gavin Eadie                        Gavin.Eadie@um.cc.umich.edu
  887. Brian Schipper                    skip@claris.com
  888. Eric Schlegel                    ericsc@microsoft.com
  889. Steven Nicolai                    nicolai@plains.NoDak.edu
  890. Herb Poppe                        hpoppe@ncar.ucar.edu
  891.  
  892.     New folks since last posting...
  893.  
  894. Paul Snively                    chewy@clarisii.claris.com
  895. Kent Sandvik                    ksand@apple.com
  896. Tom Lippincott                    lippin@math.berkeley.edu
  897. Wes W. Price II + 2                 ww2@bullwinkle.ssc.gov
  898. John Coolidge                    coolidge@cs.uiuc.edu
  899. Neal Trautman                    neal@farallon.com
  900. Mike Engber                        engber@ils.nwu.edu
  901. Kent Borg                         kent@camex.com
  902. Matthew Mora                    mxmora@unix.sri.com
  903. Tim Dierks                        ABSURD@AppleLink.Apple.COM
  904. Leonard Rosenthol                leonardr@ccs.itd.umich.edu
  905. Greg Anderson                    greggor@apple.com
  906. Jan-Erik Mangs                    kire@nada.kth.se
  907. Ragnar Sundblad                    ragge@nada.kth.se
  908. Patrik Faltstrom                paf@nada.kth.se
  909. Roy Lovejoy                        roy@adeptsln.cts.com
  910. Brian M. Hamlin                    bhamlin@netcom.com
  911. Jon Pugh                        jpugh@apple.com
  912. Martin Gannholm                    gandalf@apple.com
  913. Jerry Shields                    gshields@ima.isc.com
  914. Jeff Holcomb                    jeffh@apple.com
  915. Guy Riddle                        ggr@garage.att.com
  916. Steve Lemke                        lemke@radius.com
  917. Arno Gourdol                    Gourdol@imag.fr
  918. Laurie Kirchmeier                Laurence.Kirchmeier@um.cc.umich.edu
  919.  
  920. - --  Michael Peirce         --   peirce@outpost.SF-Bay.org
  921. - --  Peirce Software        --   Suite 301, 719 Hibiscus Place
  922. - --  Macintosh Programming  --   San Jose, California USA 95117
  923. - --           & Consulting  --   voice: (408) 244-6554 fax: (408) 244-6882
  924. - --                         --   AppleLink: peirce & America Online: AFC Peirce
  925.  
  926. +++++++++++++++++++++++++++
  927.  
  928. From: ksand@apple.com (Kent Sandvik)
  929. Date: 27 Apr 92 02:58:36 GMT
  930. Organization: MacDTS Mongols
  931.  
  932. In article <D2150035.1rnfl8@outpost.SF-Bay.org>, peirce@outpost.SF-Bay.org
  933. (Michael Peirce) writes:
  934. > We're just shy of 50 people.  I'll be checking with Gorden Biersch
  935. > about accomidating us.  I *think* they can handle it.
  936. > We'll be meeting at the main doors of the San Jose Convention Center
  937. > (where the WWDC is held) at 7:45 and then head over there en masse.
  938. > (And I though all the Mac people had defected to Windows! :-)
  939. > Stephan Somogyi                    MacUserLabs@cup.portal.com
  940. > Marshall Clow                    marshall@sdd.hp.com
  941. > Rick Holzgraf                    Rick_Holzgrafe@taligent.com
  942. > Larry Rosenstein                lsr@taligent.com
  943. > Oliver Breidenbach                breidenb@informatik.tu-muenchen.de
  944. > Michael Hecht                    Michael_Hecht@mac.sas.com
  945. > Roland Mansson                    roland.mansson@ldc.lu.se
  946. > Jon W{tte + 1                    h+@nada.kth.se
  947. > Grobbins                        grobbins@apple.com
  948. > Amanda Walker                    amanda@visix.com
  949. > Owen M. Hartnett                omh@cs.brown.edu
  950. > D. Jay Newman                    dn5@psuvm.psu.edu
  951. > Gavin Eadie                        Gavin.Eadie@um.cc.umich.edu
  952. > Brian Schipper                    skip@claris.com
  953. > Eric Schlegel                    ericsc@microsoft.com
  954. > Steven Nicolai                    nicolai@plains.NoDak.edu
  955. > Herb Poppe                        hpoppe@ncar.ucar.edu
  956. >     New folks since last posting...
  957. > Paul Snively                    chewy@clarisii.claris.com
  958. > Kent Sandvik                    ksand@apple.com
  959. > Tom Lippincott                    lippin@math.berkeley.edu
  960. > Wes W. Price II + 2                 ww2@bullwinkle.ssc.gov
  961. > John Coolidge                    coolidge@cs.uiuc.edu
  962. > Neal Trautman                    neal@farallon.com
  963. > Mike Engber                        engber@ils.nwu.edu
  964. > Kent Borg                         kent@camex.com
  965. > Matthew Mora                    mxmora@unix.sri.com
  966. > Tim Dierks                        ABSURD@AppleLink.Apple.COM
  967. > Leonard Rosenthol                leonardr@ccs.itd.umich.edu
  968. > Greg Anderson                    greggor@apple.com
  969. > Jan-Erik Mangs                    kire@nada.kth.se
  970. > Ragnar Sundblad                    ragge@nada.kth.se
  971. > Patrik Faltstrom                paf@nada.kth.se
  972. > Roy Lovejoy                        roy@adeptsln.cts.com
  973. > Brian M. Hamlin                    bhamlin@netcom.com
  974. > Jon Pugh                        jpugh@apple.com
  975. > Martin Gannholm                    gandalf@apple.com
  976. > Jerry Shields                    gshields@ima.isc.com
  977. > Jeff Holcomb                    jeffh@apple.com
  978. > Guy Riddle                        ggr@garage.att.com
  979. > Steve Lemke                        lemke@radius.com
  980. > Arno Gourdol                    Gourdol@imag.fr
  981. > Laurie Kirchmeier                Laurence.Kirchmeier@um.cc.umich.edu
  982.  
  983. Interesting, of this list (where the majority are of course Americans) we
  984. have 6.5 Swedes (I count myself as a 0.5 Swede). Are we taking over the
  985. Mac hacking world? Don't know if Greg Anderson also has a little bit
  986. viking blood in his veins?
  987.  
  988. Cheers,
  989. Kent
  990.  
  991. +++++++++++++++++++++++++++
  992.  
  993. From: peirce@outpost.SF-Bay.org (Michael Peirce)
  994. Date: 27 Apr 92 15:34:20 GMT
  995. Organization: Peirce Software
  996.  
  997.  
  998. In article <24006@goofy.Apple.COM> (comp.sys.mac.programmer), ksand@apple.com (Kent Sandvik) writes:
  999. > Interesting, of this list (where the majority are of course Americans) we
  1000. > have 6.5 Swedes (I count myself as a 0.5 Swede). Are we taking over the
  1001. > Mac hacking world? Don't know if Greg Anderson also has a little bit
  1002. > viking blood in his veins?
  1003.  
  1004. My theory is that they heard that Gorden Biersch makes EXCELLENT beer! :-)
  1005.  
  1006. - --  Michael Peirce         --   peirce@outpost.SF-Bay.org
  1007. - --  Peirce Software        --   Suite 301, 719 Hibiscus Place
  1008. - --  Macintosh Programming  --   San Jose, California USA 95117
  1009. - --           & Consulting  --   voice: (408) 244-6554 fax: (408) 244-6882
  1010. - --                         --   AppleLink: peirce & America Online: AFC Peirce
  1011.  
  1012. +++++++++++++++++++++++++++
  1013.  
  1014. From: paul@cthq.UUCP (Paul G. Smith)
  1015. Date: 29 Apr 92 14:08:52 GMT
  1016. Organization: CommsTalk HQ
  1017.  
  1018.  
  1019. Re article <D2150035.22nnsl@outpost.SF-Bay.org> (comp.sys.mac.programmer):
  1020.  
  1021. Errr... any room for a UK-based netter at the WWDC dinner?
  1022.  
  1023. We've only just got our newsfeed working, after a (long) while without a
  1024. connection, or I'd have sent this earlier.
  1025.  
  1026. Oh, and by the way: what night is it?
  1027.  
  1028. best regards, Paul
  1029.  
  1030. - -------------------------------------
  1031. Paul G Smith / CommsTalk HQ
  1032. INTERNET:  "paul@cthq.uucp"            CIX:  "pgsmith"
  1033. AppleLink: "commstalk.hq" ("commstalk.hq@applelink.apple.com")
  1034. tel/fax:   + 44 491 574295  (dial 11 on 2nd dial tone for fax)
  1035. snail:    40 St Marks Road, Henley-on-Thames, Oxon. RG9 1LW. UK
  1036.  
  1037. +++++++++++++++++++++++++++
  1038.  
  1039. From: kirchmeier@umich.edu (Laurie Kirchmeier)
  1040. Date: 30 Apr 92 14:59:52 GMT
  1041. Organization: Office of Instructional Tech./ Univ of Michigan
  1042.  
  1043. There's at least two Brits in the list - Gavin Eadie and myself.
  1044.  
  1045. +++++++++++++++++++++++++++
  1046.  
  1047. From: paul@cthq.UUCP (Paul G. Smith)
  1048. Date: 1 May 92 19:03:42 GMT
  1049. Organization: CommsTalk HQ
  1050.  
  1051.  
  1052. In article <1992Apr30.145952.13435@terminator.cc.umich.edu> (comp.sys.mac.programmer), kirchmeier@umich.edu (Laurie Kirchmeier) writes:
  1053. > There's at least two Brits in the list - Gavin Eadie and myself
  1054.  
  1055. All the better, then. :-)
  1056.  
  1057. How do I go about making myself the third, then?
  1058.  
  1059. best regards, Paul
  1060.  
  1061. - -------------------------------------
  1062. Paul G Smith / CommsTalk HQ
  1063. INTERNET:  "paul@cthq.uucp"            CIX:  "pgsmith"
  1064. AppleLink: "commstalk.hq" ("commstalk.hq@applelink.apple.com")
  1065. tel/fax:   + 44 491 574295  (dial 11 on 2nd dial tone for fax)
  1066. snail:    40 St Marks Road, Henley-on-Thames, Oxon. RG9 1LW. UK
  1067.  
  1068. ---------------------------
  1069.  
  1070. From: Jim Cook <J.Cook@ENS.Prime.COM>
  1071. Subject: Must pascal strings be even word aligned?
  1072. Organization: Prime Computer, Inc.
  1073. Date: Wed, 29 Apr 1992 21:05:45 GMT
  1074.  
  1075. In Apple Mac Tech note 189, the structure of a 'vers' resource record format
  1076. is discussed.  It contains a short and a long version string, both of which
  1077. are pascal strings.  They are compressed so the long string immediately 
  1078. follows the long string, with no padding, which means it may be odd byte
  1079. aligned.
  1080.  
  1081. The code examples in the note show the long version being copies via a 
  1082. BlockMove to another pascal string variable which is even byte aligned to
  1083. insure the long version string is even word aligned before they do anything
  1084. with it.
  1085.  
  1086. Why?
  1087.  
  1088. I haven't seen anything anywhere that says pascal strings (or any other
  1089. string for that matter) must be even byte aligned.  I was only aware of
  1090. this requirement for larger objects such as shorts, longs, etc. and only
  1091. on the 68000, not the 68020 or 68030.
  1092.  
  1093. Thanks if you can shed any light.
  1094.  
  1095. Jim
  1096. <J.Cook@ENS.Prime.COM>
  1097.  
  1098.  
  1099. +++++++++++++++++++++++++++
  1100.  
  1101. From: nebel@wam.umd.edu (Chris D. Nebel)
  1102. Organization: University of Maryland at College Park
  1103. Date: Thu, 30 Apr 1992 18:15:31 GMT
  1104.  
  1105. In article <1992Apr29.210545.2523@primerd.prime.com> <J.Cook@ENS.Prime.COM> writes:
  1106. >I haven't seen anything anywhere that says pascal strings (or any other
  1107. >string for that matter) must be even byte aligned.  I was only aware of
  1108. >this requirement for larger objects such as shorts, longs, etc. and only
  1109. >on the 68000, not the 68020 or 68030.
  1110.  
  1111. Well, you're right, it does only apply to 68000s.  But you *could* be running
  1112. on one, you know!  I think the problem is that many Pascal compilers, when
  1113. you say something like "aString := anotherString", generate code that moves
  1114. a long word at a time.  Usually this is perfectly safe, because variables
  1115. bigger than byte size are always word aligned.  BUT, sometimes you get these
  1116. structures where strings are packed together like you describe, so if you
  1117. try to do a direct string assign, you'll crash on a 68000.  I got bitten
  1118. by this one trying to fiddle with font name records in FONDs.
  1119.  
  1120. Chris Nebel
  1121. nebel@wam.umd.edu
  1122.  
  1123. +++++++++++++++++++++++++++
  1124.  
  1125. From: lsr@taligent.com (Larry Rosenstein)
  1126. Date: 1 May 92 21:58:23 GMT
  1127. Organization: Taligent, Inc.
  1128.  
  1129. In article <1992Apr29.210545.2523@primerd.prime.com>, J.Cook@ENS.Prime.COM (Jim
  1130. Cook) wrote:
  1131. > I haven't seen anything anywhere that says pascal strings (or any other
  1132. > string for that matter) must be even byte aligned.  I was only aware of
  1133.  
  1134. In fact, items in standard menus are Pascal strings and not necessarily byte
  1135. aligned.  This causes problems if you need to parse the menu data on a 68000
  1136. machine.
  1137.  
  1138. - -----
  1139. Larry Rosenstein
  1140. Taligent, Inc.
  1141. lsr@taligent.com
  1142.  
  1143. ---------------------------
  1144.  
  1145. From: an172@cleveland.Freenet.Edu (Marc A. Lombardo)
  1146. Subject: Think C buggy code
  1147. Date: 29 Apr 92 21:53:26 GMT
  1148. Organization: Case Western Reserve University, Cleveland, OH (USA)
  1149.  
  1150.  
  1151.  
  1152.   Hello!
  1153.  
  1154.   I have written a small scroller in Think C to get acquainted with pointers 
  1155. and strings in C.  I have been having some rather annoying problems with 
  1156. the code I have written, but again, I assume it is my fault and that is why 
  1157. I have decided to post the code to Usenet for people to rip apart and tell 
  1158. me what is wrong.
  1159.  
  1160.  
  1161.   The program is SUPPOSED to exit when a key is pressed, but that doesn't 
  1162. work at all.  The main problem that I am having with the code is that if I 
  1163. include the line in comments directly under the sl=strlen(scroll); 
  1164. statement, the scroller will work! (Well, I haven't tested it completely, 
  1165. but it looks like it is scrolling!)  If I do NOT include this line, it will 
  1166. not scroll at all!  The problem is that this line has nothing to do with the 
  1167. scroller as far as I know... All I am doing is printing 7 spaces, no less, 
  1168. to the screen with a \n at the end.  For some reason this makes the scroller 
  1169. work.
  1170.  
  1171.   I would be very happy to know why this happens, for I came upon it by 
  1172. complete accident!  But, if you see some other problems in my code, or have 
  1173. suggestions about how to do something differently, I would be happy to hear 
  1174. what you have to say, for I am learning C all on my own, and I can use all 
  1175. of the help I can get.
  1176.  
  1177.      Please reply via email!
  1178.  
  1179.  
  1180. Here is the buggy code:  (pretty short!)
  1181.  
  1182.  
  1183.  
  1184. - ----
  1185.  
  1186. #include <stdio.h>
  1187. #include <console.h>
  1188.  
  1189. main()
  1190. {
  1191.      char ch;
  1192.      char *scroll,temp[10];
  1193.  
  1194.      int x,sl,i,t;
  1195.      csetmode(C_RAW,stdin);
  1196.  
  1197.      scroll="This is a test of the emergency broadcast system... this is 
  1198. only a test.  If this were a real emergency then this test would be followed 
  1199. by blah blah blah blah blah";
  1200.      
  1201.      sl=strlen(scroll);
  1202.  
  1203.   /* printf("       \n");     */
  1204.  
  1205.      for(x=0;x<10;x++)  {               /* Can you forget about the
  1206.           temp[x]=scroll[x];               brackets if there is only
  1207.      }                                     one line in your loop?  */
  1208.  
  1209.      strcat(scroll,temp);
  1210.  
  1211.      ch=-1;
  1212.  
  1213.      while (ch==-1) {
  1214.           for(x=0;x<sl-10;x++) {
  1215.                if ((ch=getchar())==-1) {
  1216.                     t=0;
  1217.                     for(i=x;i<x+10;i++) {
  1218.                          temp[t++]=scroll[i];
  1219.                     }
  1220.                     cgotoxy(10,10,stdout);
  1221.                     printf("%s",temp);
  1222.                }
  1223.           }
  1224.      }
  1225. }
  1226.  
  1227. - -- 
  1228. Marc A. Lombardo                                            User Address: an172
  1229. /-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\
  1230.     Compuserve:  >INTERNET: an172@cleveland.freenet.edu
  1231.     Internet/BitNET:  an172@cleveland.freenet.edu         Atari ST,MIDI,Music
  1232.  
  1233. +++++++++++++++++++++++++++
  1234.  
  1235. From: brianc@acuson.com (Brian Cox)
  1236. Date: 30 Apr 92 20:23:22 GMT
  1237. Organization: Acuson; Mountain View, California
  1238.  
  1239. an172@cleveland.Freenet.Edu (Marc A. Lombardo) writes:
  1240.  
  1241. First of all, it is not unusual for printf() to alter the behavior of
  1242. seemingly unrelated bugs.  It scrambles the stack up and tends to move
  1243. things around.
  1244.  
  1245.  
  1246. >Here is the buggy code:  (pretty short!)
  1247.  
  1248.  
  1249.  
  1250. >----
  1251.  
  1252. >#include <stdio.h>
  1253. >#include <console.h>
  1254.  
  1255. >main()
  1256. >{
  1257. >     char ch;
  1258. >     char *scroll,temp[10];
  1259.  
  1260. >     int x,sl,i,t;
  1261. >     csetmode(C_RAW,stdin);
  1262.  
  1263. >     scroll="This is a test of the emergency broadcast system... this is 
  1264. >only a test.  If this were a real emergency then this test would be followed 
  1265. >by blah blah blah blah blah";
  1266.  
  1267. So: we have a pointer "scroll" which points at a block of static memory
  1268.     which has "This is a test...blah"  The block of memory is exactly as
  1269.     long as the text you typed in.  This is important for later...
  1270. >     
  1271. >     sl=strlen(scroll);
  1272.  
  1273. >  /* printf("       \n");     */
  1274.  
  1275. >     for(x=0;x<10;x++)  {               /* Can you forget about the
  1276. >          temp[x]=scroll[x];               brackets if there is only
  1277. >     }                                     one line in your loop?  */
  1278.  
  1279. Now: we copy the first 10 bytes from scroll into temp.  Note that temp
  1280.      now has 10 bytes in it, but no null termination.  strcat() really
  1281.      prefers that its arguments be null terminated.  Note also that if
  1282.      you added a line: temp[x] = '\0'; after the for loop, you would
  1283.      be off the end of the array.
  1284.  
  1285. >     strcat(scroll,temp);
  1286.  
  1287. Ahh: here is where the problem comes to a head!  temp is not null terminated
  1288.      and scroll is only big enough to hold what it already contains!  Who
  1289.      knows how many bytes will be copied from temp until the random data
  1290.      beyond happens to be 0?  And who knows what variable, whose memory
  1291.      happens to be right after scroll, will be overwritten in this "drive-by"
  1292.      shooting?  This is exactly the sort of behavior which can be altered
  1293.      by inserting printf()'s by the way.
  1294.  
  1295. >     ch=-1;
  1296.  
  1297. We're already screwed up by the time we get here.  But you want to watch out
  1298. for putting negative values into char variables.  Some compilers treat chars
  1299. as unsigned.  I don't recall off the top of my head, but I think that this 
  1300. is OK in THINK C...
  1301.  
  1302. >     while (ch==-1) {
  1303. >          for(x=0;x<sl-10;x++) {
  1304. >               if ((ch=getchar())==-1) {
  1305.  
  1306. You will notice that in K&R, that c, which gets the value of getchar() is
  1307. declared an int for the very reason I mentioned above.
  1308.  
  1309. >                    t=0;
  1310. >                    for(i=x;i<x+10;i++) {
  1311. >                         temp[t++]=scroll[i];
  1312. >                    }
  1313. >                    cgotoxy(10,10,stdout);
  1314. >                    printf("%s",temp);
  1315. >               }
  1316. >          }
  1317. >     }
  1318. >}
  1319.  
  1320. >-- 
  1321. >Marc A. Lombardo                                            User Address: an172
  1322. >/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\-/-\
  1323. >    Compuserve:  >INTERNET: an172@cleveland.freenet.edu
  1324. >    Internet/BitNET:  an172@cleveland.freenet.edu         Atari ST,MIDI,Music
  1325.  
  1326. Hope this was informative and not too insulting.
  1327.  
  1328.                 -_Brian Cox_-
  1329.  
  1330. - -- 
  1331. - --------------------------------------------------------------------------------
  1332. Make sure that you do not to overanalyze the crud that comes out of your
  1333. keyboard when you turn it upside down and shake it...
  1334.  
  1335. ---------------------------
  1336.  
  1337. End of C.S.M.P. Digest
  1338. **********************
  1339.